package cn.itcast.nems.manager.auth;

/**
 * author: yong.li
 * create: 2023-08-18 14:12:15
 **/
class KCAccessToken {
    private long createTime;
    private int expiresIn;
    private String token;
    private static final long TEN_MINUTE = 10 * 60 * 1000;

    KCAccessToken(String token, int expiresIn) {
        this.createTime = System.currentTimeMillis();
        this.token = token;
        this.expiresIn = expiresIn;
    }

    String getToken() {
        return this.token;
    }

    boolean isValid() {
        long ctime = System.currentTimeMillis();
        long dt = (this.createTime + this.expiresIn * 1000) - ctime;
        return dt > TEN_MINUTE;
    }
}
